package com.xckj.service.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.xckj.dao.JacgSpringBeanMapper;
import com.xckj.entity.JacgSpringBean;
import com.xckj.service.JacgSpringBeanService;
import com.xckj.utils.ReturnT;

/**
 * @description Spring Bean信息表
 * @author yanchf
 * @date 2023-12-03
 */
@Service
public class JacgSpringBeanServiceImpl implements JacgSpringBeanService {

	@Resource
	private JacgSpringBeanMapper jacgSpringBeanMapper;


	@Override
	public Object insert(JacgSpringBean jacgSpringBean) {

		// valid
		if (jacgSpringBean == null) {
			return ReturnT.error("必要参数缺失");
        }

		jacgSpringBeanMapper.insert(jacgSpringBean);
        return ReturnT.success();
	}


	@Override
	public Object delete(int id) {
		int ret = jacgSpringBeanMapper.delete(id);
		return ret>0?ReturnT.success():ReturnT.error();
	}


	@Override
	public Object update(JacgSpringBean jacgSpringBean) {
		int ret = jacgSpringBeanMapper.update(jacgSpringBean);
		return ret>0?ReturnT.success():ReturnT.error();
	}


	@Override
	public JacgSpringBean load(int id) {
		return jacgSpringBeanMapper.load(id);
	}


	@Override
	public Map<String,Object> pageList(int offset, int pagesize) {

		List<JacgSpringBean> pageList = jacgSpringBeanMapper.pageList(offset, pagesize);
		int totalCount = jacgSpringBeanMapper.pageListCount(offset, pagesize);

		// result
		Map<String, Object> result = new HashMap<String, Object>();
		result.put("pageList", pageList);
		result.put("totalCount", totalCount);

		return result;
	}

}